package com.ruoyi.system.coretools.apple;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.util.Map;
@Slf4j
public class JsonHelper {
    private final static ObjectMapper objectMapper = new ObjectMapper();

    public static Map<String,Object> toMap(JsonNode jsonNode){
        return objectMapper.convertValue(jsonNode, new TypeReference<Map<String, Object>>(){});
    }
    public static JsonNode asTree(String strJson) {
        try {
            return objectMapper.readTree(strJson);
        } catch (IOException e) {
            log.error("Deserialize fail", e);
        }
        return null;
    }
}
